package com.th.supcom.pds.impl.service.internal.phamapply;

import java.util.List;

import net.carefx.framework.exception.BusinessException;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.th.supcom.pds.domain.pojo.PdsPatPhamRemain;
import com.th.supcom.pds.impl.common.PdsConstants;
import com.th.supcom.pds.impl.manager.PdsPatPhamRemainManager;
import com.th.supcom.pds.internal.api.phamapply.InpPatPhamLeftBasicService;

public class InpPatPhamLeftBasicServiceImpl implements InpPatPhamLeftBasicService
{
    /** 日志记录器. */
    public static final Logger s_logger = LoggerFactory.getLogger (InpPatPhamLeftBasicServiceImpl.class);
    private PdsPatPhamRemainManager m_pdsPatPhamRemainManager;

    public void setPdsPatPhamRemainManager (PdsPatPhamRemainManager pdsPatPhamRemainManager)
    {
        m_pdsPatPhamRemainManager = pdsPatPhamRemainManager;
    }

    @Override
    public PdsPatPhamRemain getPdsPatPhamRemainByID (Long id)
    {
        s_logger.info ("调用getPdsPatPhamRemainByID参数 ：id:{}", new Object[]
        { id });
        if (null == id)
        {
            s_logger.error ("通过主键查询住院患者药品剩余数量时，主键不能为空");
            throw new IllegalArgumentException ("通过主键查询住院患者药品剩余数量时，主键不能为空");
        }
        try
        {
            return m_pdsPatPhamRemainManager.getPdsPatPhamRemainByID (id);
        }
        catch (Exception e)
        {
            s_logger.error ("通过主键查询住院患者药品剩余数量异常" + e.getLocalizedMessage (), e);
            throw new BusinessException ("通过主键查询住院患者药品剩余数量异常" + PdsConstants.DEFALUT_HTML_WRAP, e);
        }
    }

    @Override
    public List <PdsPatPhamRemain> findPdsPatPhamRemainListByExample (PdsPatPhamRemain inpPatPhamLeft)
    {
        s_logger.info ("调用findPdsPatPhamRemainListByExample参数 ：inpPatPhamLeft:{}", new Object[]
        { inpPatPhamLeft });
        if (null == inpPatPhamLeft)
        {
            s_logger.error ("通过条件查询住院患者药品剩余数量时，条件对象不能为空");
            throw new IllegalArgumentException ("通过条件查询住院患者药品剩余数量时，条件对象不能为空");
        }
        try
        {
            return m_pdsPatPhamRemainManager.findPdsPatPhamRemainListByExample (inpPatPhamLeft);
        }
        catch (Exception e)
        {
            s_logger.error ("通过条件查询住院患者药品剩余数量异常" + e.getLocalizedMessage (), e);
            throw new BusinessException ("通过条件查询住院患者药品剩余数量异常" + PdsConstants.DEFALUT_HTML_WRAP, e);
        }
    }

    @Override
    public int findPdsPatPhamRemainCountByExample (PdsPatPhamRemain inpPatPhamLeft)
    {
        s_logger.info ("调用findPdsPatPhamRemainCountByExample参数 ：inpPatPhamLeft:{}", new Object[]
        { inpPatPhamLeft });
        if (null == inpPatPhamLeft)
        {
            s_logger.error ("通过条件查询住院患者药品剩余数量记录数时，条件对象不能为空");
            throw new IllegalArgumentException ("通过条件查询住院患者药品剩余数量记录数时，条件对象不能为空");
        }
        try
        {
            return m_pdsPatPhamRemainManager.findPdsPatPhamRemainCountByExample (inpPatPhamLeft);
        }
        catch (Exception e)
        {
            s_logger.error ("通过条件查询住院患者药品剩余数量记录数异常" + e.getLocalizedMessage (), e);
            throw new BusinessException ("通过条件查询住院患者药品剩余数量记录数异常" + PdsConstants.DEFALUT_HTML_WRAP, e);
        }
    }

    @Override
    public int modifyPdsPatPhamRemain (PdsPatPhamRemain inpPatPhamLeft)
    {
        s_logger.info ("调用modifyPdsPatPhamRemain参数 ：inpPatPhamLeft:{}", new Object[]
        { inpPatPhamLeft });
        if (null == inpPatPhamLeft)
        {
            s_logger.error ("更新住院患者药品剩余数量时，对象不能为空");
            throw new IllegalArgumentException ("更新住院患者药品剩余数量时，对象不能为空");
        }
        try
        {
            return m_pdsPatPhamRemainManager.modifyPdsPatPhamRemain (inpPatPhamLeft);
        }
        catch (Exception e)
        {
            s_logger.error ("更新住院患者药品剩余数量异常" + e.getLocalizedMessage (), e);
            throw new BusinessException ("更新住院患者药品剩余数量异常" + PdsConstants.DEFALUT_HTML_WRAP, e);
        }
    }

    @Override
    public int modifyPdsPatPhamRemainByExample (PdsPatPhamRemain inpPatPhamLeft)
    {
        s_logger.info ("调用modifyPdsPatPhamRemainByExample参数 ：inpPatPhamLeft:{}", new Object[]
        { inpPatPhamLeft });
        if (null == inpPatPhamLeft)
        {
            s_logger.error ("更新住院患者药品剩余数量时，对象不能为空");
            throw new IllegalArgumentException ("更新住院患者药品剩余数量时，对象不能为空");
        }
        try
        {
            return m_pdsPatPhamRemainManager.modifyPdsPatPhamRemainByExample (inpPatPhamLeft);
        }
        catch (Exception e)
        {
            s_logger.error ("更新住院患者药品剩余数量异常" + e.getLocalizedMessage (), e);
            throw new BusinessException ("更新住院患者药品剩余数量异常" + PdsConstants.DEFALUT_HTML_WRAP, e);
        }
    }

    @Override
    public void addPdsPatPhamRemain (PdsPatPhamRemain inpPatPhamLeft)
    {
        s_logger.info ("调用addPdsPatPhamRemain参数 ：inpPatPhamLeft:{}", new Object[]
        { inpPatPhamLeft });
        if (null == inpPatPhamLeft)
        {
            s_logger.error ("保存住院患者药品剩余数量时，对象不能为空");
            throw new IllegalArgumentException ("保存住院患者药品剩余数量时，对象不能为空");
        }
        try
        {
            m_pdsPatPhamRemainManager.modifyPdsPatPhamRemainByExample (inpPatPhamLeft);
        }
        catch (Exception e)
        {
            s_logger.error ("保存住院患者药品剩余数量异常" + e.getLocalizedMessage (), e);
            throw new BusinessException ("保存住院患者药品剩余数量异常" + PdsConstants.DEFALUT_HTML_WRAP, e);
        }

    }

    @Override
    public int removePdsPatPhamRemainByID (Long id)
    {
        s_logger.info ("调用getPdsPatPhamRemainByID参数 ：id:{}", new Object[]
        { id });
        if (null == id)
        {
            s_logger.error ("通过主键删除住院患者药品剩余数量时，主键不能为空");
            throw new IllegalArgumentException ("通过主键删除住院患者药品剩余数量时，主键不能为空");
        }
        try
        {
            return m_pdsPatPhamRemainManager.removePdsPatPhamRemainByID (id);
        }
        catch (Exception e)
        {
            s_logger.error ("通过主键删除住院患者药品剩余数量异常" + e.getLocalizedMessage (), e);
            throw new BusinessException ("通过主键删除住院患者药品剩余数量异常" + PdsConstants.DEFALUT_HTML_WRAP, e);
        }
    }

    @Override
    public List <PdsPatPhamRemain> findPatPhamRemainsByPaiVisitIdList (List <Long> paiVisitIdList)
    {
        s_logger.info ("调用findPatPhamRemainsByPaiVisitIdList参数 ：paiVisitIdList:{}", new Object[]
        { paiVisitIdList });
        if (paiVisitIdList.isEmpty ())
        {
            s_logger.error ("通过患者住院号查询住院患者药品剩余数量时，住院号不能为空");
            throw new IllegalArgumentException ("通过患者住院号查询住院患者药品剩余数量时，住院号不能为空");
        }
        try
        {
            return m_pdsPatPhamRemainManager.findPatPhamRemainsByPaiVisitIdList (paiVisitIdList);
        }
        catch (Exception e)
        {
            s_logger.error ("通过患者住院号查询住院患者药品剩余数量异常" + e.getLocalizedMessage (), e);
            throw new BusinessException ("通过患者住院号查询住院患者药品剩余数量异常" + PdsConstants.DEFALUT_HTML_WRAP, e);
        }
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.th.supcom.pds.internal.api.phamapply.InpPatPhamLeftBasicService#
     * addPdsPatPhamRemainList(java.util.List)
     */
    @Override
    public void addPdsPatPhamRemainList (List <PdsPatPhamRemain> list)
    {
        s_logger.info ("调用addPdsPatPhamRemainList参数 ：list:{}", new Object[]
        { list });
        if (list.isEmpty ())
        {
            s_logger.error ("批量添加住院患者药品剩余数量时，保存对象不能为空");
            throw new IllegalArgumentException ("批量添加住院患者药品剩余数量时，保存对象不能为空");
        }
        try
        {
            m_pdsPatPhamRemainManager.addPdsPatPhamRemainList (list);
        }
        catch (Exception e)
        {
            s_logger.error ("批量添加住院患者药品剩余数量异常" + e.getLocalizedMessage (), e);
            throw new BusinessException ("批量添加住院患者药品剩余数量异常" + PdsConstants.DEFALUT_HTML_WRAP, e);
        }
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.th.supcom.pds.internal.api.phamapply.InpPatPhamLeftBasicService#
     * modifyPdsPatPhamRemainList(java.util.List)
     */
    @Override
    public int modifyPdsPatPhamRemainList (List <PdsPatPhamRemain> list)
    {
        s_logger.info ("调用modifyPdsPatPhamRemainList参数 ：list:{}", new Object[]
        { list });
        if (list.isEmpty ())
        {
            s_logger.error ("批量更新住院患者药品剩余数量时，更新对象不能为空");
            throw new IllegalArgumentException ("批量更新住院患者药品剩余数量时，更新对象不能为空");
        }
        try
        {
            return m_pdsPatPhamRemainManager.modifyPdsPatPhamRemainList (list);
        }
        catch (Exception e)
        {
            s_logger.error ("批量更新住院患者药品剩余数量异常" + e.getLocalizedMessage (), e);
            throw new BusinessException ("批量更新住院患者药品剩余数量异常" + PdsConstants.DEFALUT_HTML_WRAP, e);
        }
    }

    /** 公司版权信息. */
    public static final String copyright = "Copyright 2014, XuNuo Corporation";

    /** 提交路径. */
    public static final String SCC_BRANCH = "$URL$";

    /** 提交日期. */
    public static final String SCC_LAST_MODIFICATION_DATE = "$Date$";

    /** 最终修改人员. */
    public static final String SCC_LAST_MODIFIER_NAME = "$Author$";

    /** 最终版本号. */
    public static final String SCC_REVISION = "$Revision$";

}
